/**
 * 定义一个泛型别名，要求满足所有的服务器返回的数据
 */

type ApiRes<T> = {
  code: number
  data: T
  message: string
}

type User = {
  nickname: string
  avatar: string
  qq?: string
}

// 后台返回的用户信息数据
const res: ApiRes<User> = {
  code: 200,
  data: {
    nickname: 'wenqing',
    avatar: 'http://wwwxxx.png',
    qq: '10002'
  },
  message: '请求成功'
}

console.log(res)

// 后台返回的轮播图列表数据
type Swiper = {
  bannerid: string
  flag: boolean
  alt: string
  img: string
  link: string
}

const res1: ApiRes<Swiper[]> = {
  code: 200,
  data: [
    {
      alt: 'banner1',
      bannerid: 'banner_a9d2cc59-1ed3-4e74-a4e2-58e79cac1f30',
      flag: true,
      img: '//imgcps.jd.com/img-cubic/creative_server_cia_jdcloud/v2/2000267/100058721733/FocusFullshop/CkFqZnMvdDEvMTY4OS8yMS8yMTYxNi81MzE2Ni82NDZiYzIwNEZkZWEyMGVmNy9lODFiYWViZDhlNTg3OTU2LnBuZxILNTExLXR5XzBfNDkwATiLi3pCIAoc5ryr5q2l6ICF6JOd54mZL-aXoOe6v-iAs-acuhABQhYKEuW8gOWQr-eyvuiHtOeUn-a0uxACQhAKDOeri-WNs-aKoui0rRAGQgoKBui2heWAvBAHWMXb29_0Ag/cr_1125x449_0_166/s/q70.jpg',
      link: 'https://www.taobao.com'
    },
    {
      alt: 'banner1',
      bannerid: 'banner_a9d2cc59-1ed3-4e74-a4e2-58e79cac1f30',
      flag: true,
      img: '//imgcps.jd.com/img-cubic/creative_server_cia_jdcloud/v2/2000267/100058721733/FocusFullshop/CkFqZnMvdDEvMTY4OS8yMS8yMTYxNi81MzE2Ni82NDZiYzIwNEZkZWEyMGVmNy9lODFiYWViZDhlNTg3OTU2LnBuZxILNTExLXR5XzBfNDkwATiLi3pCIAoc5ryr5q2l6ICF6JOd54mZL-aXoOe6v-iAs-acuhABQhYKEuW8gOWQr-eyvuiHtOeUn-a0uxACQhAKDOeri-WNs-aKoui0rRAGQgoKBui2heWAvBAHWMXb29_0Ag/cr_1125x449_0_166/s/q70.jpg',
      link: 'https://www.taobao.com'
    }
  ],
  message: '查看轮播图'
}

console.log('---res1---', res1)

export {}
